package route

import (
	"time"

	"gitee.com/jiebaiyou/formflow/api/controller"
	"gitee.com/jiebaiyou/formflow/bootstrap"
	"gitee.com/jiebaiyou/formflow/pkg/storage/redis"
	"gitee.com/jiebaiyou/formflow/pkg/storage/sqlite"
	"gitee.com/jiebaiyou/formflow/repository"
	"gitee.com/jiebaiyou/formflow/service"
	"github.com/gin-gonic/gin"
)

// NewProfileRouter 创建并配置用户资料相关的API路由
func NewProfileRouter(env *bootstrap.Config, timeout time.Duration, db sqlite.DB, cache redis.Database, group *gin.RouterGroup) {
	// 初始化用户仓储
	ur := repository.NewUserRepository(db, cache)
	// 初始化资料服务
	ps := service.NewProfileService(ur, timeout)
	// 创建资料控制器
	pc := &controller.ProfileController{
		ProfileService: ps, // 注入资料用例
	}

	// 注册获取资料路由
	group.GET("/profile", pc.Fetch)
}
